
<template>
  <div class="printForm">
    <div class="area-header">
      <span class="area-header-title">{{ $t('加班申请') }}</span>
    </div>
    <table class="printTable">
      <tr>
        <td class="tit">{{ $t('申请标题') }}</td>
        <td colspan="3">{{ form.actTitle }}</td>
      </tr>
      <tr>
        <td class="tit">{{ $t('申请人') }}</td>
        <td>
          <UserSelect
            v-model="form.username"
          />
        </td>
        <td class="tit">{{ $t('申请部门') }}</td>
        <td>
          <DeptSelect v-model="form.deptId" />
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('岗位/职务') }}</td>
        <td>
          {{ $t(form.postNames) }}
        </td>
        <td class="tit">{{ $t('开始时间') }}</td>
        <td>
          {{ parseTime(form.startDate) }}
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('结束时间') }}</td>
        <td>
          {{ parseTime(form.endDate) }}
        </td>
        <td class="tit">{{ $t('加班天数') }}</td>
        <td>
          {{ form.applicationDuration }}
        </td>
      </tr>
      <tr>
        <td class="tit">{{ $t('加班原因') }}</td>
        <td colspan="3">
          {{ form.remark }}
        </td>
      </tr>
    </table>
    <!-- 附件列表 -->
    <FileView :list.sync="form.fileList" data-type="anxin_overtime" :btn-show="!otherBtnHide" />
  </div>
</template>

<script>
import { getAnxinOvertimeApplication } from '@/api/anxin/overtime/anxinOvertimeApplication'
import { getUserProfile } from '@/api/system/user'
export default {
  components: {
  },
  data() {
    return {
      // 表单参数
      form: {},
      // 遮罩层
      loading: false,
      otherBtnHide: false
    }
  },
  created() {
    this.$bus.$emit('async_done')
  },
  methods: {
    // 初始化数据
    init(data) {
      console.log(data)
      this.loading = true
      if (data != null && data.id !== undefined) {
        getAnxinOvertimeApplication(data.id).then((response) => {
          this.form = response.data
          this.loading = false
        })
      } else {
        getUserProfile().then((response) => {
          this.form.username = response.data.id
          this.loading = false
        })
      }
    }
  }
}
</script>
